<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

/**
 * 微信会员卡扩展表
 */
class WxCardMember extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        //会员卡扩展表
        Schema::create('wx_card_members', function (Blueprint $table) {
            $table->increments('id')->comment('自增序号');
            $table->string('appid', 64)->default('')->comment('微信应用ID');
            $table->unsignedInteger('card_base_id')->default(0)->comment('卡券主键唯一ID');
            $table->string('background_pic_url', 200)->default('')->comment('自定义会员卡背景图');
            $table->text('prerogative')->nullable()->comment('会员卡特权说明');
            $table->text('activate')->nullable()->comment('会员卡激活信息');
            $table->text('service_statement')->nullable()->comment('服务声明信息');
            $table->text('bind_old_card')->nullable()->comment('绑定老会员链接信息');
            $table->text('bonus')->nullable()->comment('积分设置信息');
            $table->text('balance')->nullable()->comment('余额设置信息');
            $table->text('custom_field1')->nullable()->comment('自定义会员信息类目一,name_type、name、url');
            $table->text('custom_field2')->nullable()->comment('自定义会员信息类目二,name_type、name、url');
            $table->text('custom_field3')->nullable()->comment('自定义会员信息类目三,name_type、name、url');
            $table->text('custom_cell1')->nullable()->comment('自定义会员信息类目');
            $table->text('custom_cell2')->nullable()->comment('自定义会员信息类目');
            $table->text('custom_cell3')->nullable()->comment('自定义会员信息类目');
            $table->text('bonus_rule')->nullable()->comment('积分规则');
            $table->unsignedInteger('discount')->default(0)->comment('折扣，该会员卡享受的折扣优惠,填10就是九折');
            $table->softDeletes();
            $table->timestamps();
            $table->index(['appid','card_base_id','deleted_at'], 'idx_1');
        });
        //会员卡等级表
        Schema::create('wx_card_member_levels', function (Blueprint $table) {
            $table->increments('id')->comment('自增序号');
            $table->string('appid', 64)->default('')->comment('微信应用ID');
            $table->unsignedInteger('card_base_id')->default(0)->comment('卡券主键唯一ID');
            $table->string('key', 50)->default('')->comment('等级标识');
            $table->string('name', 100)->default('')->comment('会员等级名称');
            $table->text('description')->nullable()->comment('描述');
            $table->string('background_pic_url', 200)->default('')->comment('自定义会员卡背景图');
            $table->unsignedTinyInteger('give_bonus')->default(0)->comment('奖励积分');
            $table->string('give_coupon')->default('')->comment('奖励优惠券标识');
            $table->unsignedTinyInteger('order_num')->default(0)->comment('排序');
            $table->softDeletes();
            $table->timestamps();
            $table->index(['appid','card_base_id','deleted_at'], 'idx_1');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('wx_card_members');
        Schema::dropIfExists('wx_card_member_levels');
    }
}
